package com.tiancheng.trade.order.service;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.core.exception.BusinessException;
import com.tiancheng.trade.order.bo.*;
import com.tiancheng.trade.order.bo.cmq.CreditOrderFundAuthFreezeBo;
import com.tiancheng.trade.order.model.CreditOrder;
import com.tiancheng.trade.commom.core.data.MessageBody;
import com.tiancheng.trade.order.vo.api.CreditOrderCancelVo;
import com.tiancheng.trade.order.vo.api.CreditOrderFinishVO;
import com.tiancheng.trade.order.vo.api.CreditOrderVo;

import java.util.List;

/**
 * 信用订单表Service接口
 *
 * @author likailun
 * @date 2024-09-16
 */
public interface CreditOrderService {
    /**
     * 创建信用订单
     * @param orderBO
     */
    void create(OrderBO orderBO, List<SubOrderBO> subOrderBOS) throws BusinessException;

    /**
     * 获取支付宝支付：orderStr
     * @param orderId
     * @param compatible
     * @return
     */
    String getOrderStr(String orderId, String compatible) throws BusinessException;

    /**
     * 完成预授权订单流程
     * @param creditOrderFinishVO
     * @return
     */
    Result finishCreditOrder(CreditOrderFinishVO creditOrderFinishVO) throws BusinessException;

    /**
     * 取消预授权订单
     * @return
     */
    Result cancel(CreditOrderCancelVo orderCancel) throws BusinessException;

    /**
     * 回调——用户预授权回调确认，修改芝麻信用订单号、支付宝账号等信息
     * @param payNotifyBO
     */
    CreditOrder updateFundAuthFreeze(CreditOrderFundAuthFreezeBo payNotifyBO);

    /**
     * 回调——预授权转支付通知回调
     * @param gwOrderId
     */
    CreditOrder tradeStatusSync(String gwOrderId);

    /**
     * 回调——预授权订单取消成功
     * @param gwOrderId
     * @param requestNo
     */
    CreditOrder cancelConfirm(String gwOrderId, String requestNo);
    /**
     * 回调——预授权订单解冻成功
     * @param requestNo
     */
    CreditOrder fundAuthUnfreeze(String gwOrderId,String requestNo);

    /**
     * 根据alipayAuthNo查询查询预授权订单
     * @param alipayAuthNo
     * @param compatible
     * @return
     */
    Result<CreditOrderVo> queryCreditOrderByAlipayAuthNo(String alipayAuthNo, String compatible) throws BusinessException;

    CreditOrderVo queryConfirmStatusByOrderId(String orderId, String compatible) throws BusinessException;


    /**
     * 修改老系统退款单状态
     * @param messageBody
     * @return
     */
    Result updateCreditOrderState(MessageBody messageBody);
}
